﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tomato.Serialization;
using System.IO;

namespace Tomato
{
    public static class StringExtension
    {
        public static T JsonToObject<T>(this string s)
        {
            return new JsonDeserializer().Deserialize<T>(s);
        }

        public static T JsonBase64ToObject<T>(this string s)
        {
            using (MemoryStream stream = new MemoryStream(Convert.FromBase64String(s)))
            {
                return new JsonDeserializer().Deserialize<T>(stream);
            }
        }
    }
}
